package com.ctshk.sapp.ship.controller;


import com.ctshk.common.annotations.OperationLogAnnotation;
import com.ctshk.common.dto.Result;
import com.ctshk.common.enums.OperationLogModel;
import com.ctshk.common.enums.OperationLogType;
import com.ctshk.common.model.TokenUser;
import com.ctshk.common.web.support.BaseController;
import com.ctshk.rpc.ship.req.ShipInitializationSettingsSaveReq;
import com.ctshk.rpc.ship.service.IShipInitializationSettingsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * <p>
 * 船票api初始化设置表 前端控制器
 * </p>
 *
 * @author 刘蕾
 * @since 2021-03-26
 */
@Api(value = "船票api初始化设置表",tags = "船票api初始化设置表")
@RestController
@RequestMapping("/ship-initialization-settings")
public class ShipInitializationSettingsController extends BaseController {

    @DubboReference
    IShipInitializationSettingsService shipInitializationSettingsService;


    @ApiOperation(value = "新增船票api设置", notes = "新增船票api设置")
    @OperationLogAnnotation(operModul = OperationLogModel.TICKET, operType = OperationLogType.ADD, operTitle = "新增船票api设置", operDesc = "新增船票api设置")
    @PostMapping("/save")
    public Result saveBusProduct(@RequestBody @Valid ShipInitializationSettingsSaveReq shipInitializationSettingsSaveReq) {
        TokenUser user = getCurrentUser(getRequest());
        return shipInitializationSettingsService.save(shipInitializationSettingsSaveReq, user);
    }

    @ApiOperation(value = "船票api设置详情", notes = "船票api设置详情")
    @OperationLogAnnotation(operModul = OperationLogModel.TICKET, operType = OperationLogType.ADD, operTitle = "新增船票api设置", operDesc = "新增船票api设置")
    @PostMapping("/detail")
    public Result detail(@RequestBody ShipInitializationSettingsSaveReq shipInitializationSettingsSaveReq) {
        return shipInitializationSettingsService.detail(shipInitializationSettingsSaveReq);
    }
}
